from flask import Flask
# from flask_sqlalchemy import SQLAlchemy

from routes.pdf2img_routes import bp as pdf2img_routes
from routes.rmblank_routes import bp as rmblank_routes
from routes.index_routes import bp as index_routes
from routes.wechat_routes import bp as wechat_routes
import os

app = Flask(__name__, static_folder="static")
app.config['DEBUG'] = True
# app.config['SQLALCHEMY_DATABASE_URI'] = "mysql+pymysql://root:123456@localhost:3306/pdf2img"
# 设置是否跟踪数据库的修改情况，一般不跟踪
# app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
# 数据库操作时是否显示原始SQL语句，一般都是打开的，因为我们后台要日志
# app.config['SQLALCHEMY_ECHO'] = True
# db = SQLAlchemy(app)


app.register_blueprint(pdf2img_routes)
app.register_blueprint(rmblank_routes)
app.register_blueprint(index_routes)
app.register_blueprint(wechat_routes)

UPLOAD_FOLDER = "static/pdf"
if not os.path.exists(UPLOAD_FOLDER):
    os.makedirs(UPLOAD_FOLDER)
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER

RM_BLANK_UPLOAD_FOLDER = "static/rmblank"
if not os.path.exists(RM_BLANK_UPLOAD_FOLDER):
    os.makedirs(RM_BLANK_UPLOAD_FOLDER)
app.config['RM_BLANK_UPLOAD_FOLDER'] = RM_BLANK_UPLOAD_FOLDER

DOWNLOAD_FOLDER = "static/2img"
if not os.path.exists(DOWNLOAD_FOLDER):
    os.makedirs(DOWNLOAD_FOLDER)
app.config['DOWNLOAD_FOLDER'] = DOWNLOAD_FOLDER

app.run(host="127.0.0.1", port=5000)
